<template>
	<view class="mainpadding">
		<view class="" style="padding-bottom: 140rpx;">
			<view class="flexcenter" v-if="!list.data.length">
				<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
			</view>
			<view class="shangj mainpadding ffffff radius" v-for="item in list.data" :key="item.id">
				<view class="xiahuaxian">
					<view class="strongtext xiaohei nofonweight">跟进记录：{{item.des}}</view>
					<view class="strongtext xiaohui nofonweight margin_top1">时间：{{item.createtime_text}}</view>
				</view>
				<view class="flexleft flex_wrap">
					<view class="sanshis flexcenter margin_top2" v-for="(ite,inde) in item.images_text" :key="inde">
						<view class="jiaolt">
							<image :src="ite" mode="" @click="lbtpriview(inde,item.images_text)"></image>
						</view>
					</view>
				</view>
				<view class="flexright margin_top">
					<view class="baibtn margin_right2" @click="delitem(item.id)">移除</view>
					<view class="lvbtn" @click="bianji(item.id)">编辑记录</view>
				</view>
			</view>
		</view>
		<!-- 固定底部 -->
		<view class="gudingdb mainpadding">
			<view class="bigbtn" @click="xinjian">新建跟进记录</view>
		</view>
		<!-- <view class="gudingdb ffffff mainpadding flexcenter" @click="jumper('/pages_xiaoshou/xinjiangenjinjl')">
			<view class="margin_right1">
				<u-icon name="plus-circle" color="#000000" size="22"></u-icon>
			</view>
			<view class="strongtext nofonweight xiaohei">新建跟进记录</view>
		</view> -->
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				listid:"",
				modal:{
					modalShow:false,
					title:"是否确认删除当前记录？",
				},
				currentid:"",
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			this.init()
		},
		methods: {
			delitem(id){
				this.modal.modalShow = true
				this.currentid = id
			},
			modalSure(){
				if(this.modal.title=="是否确认删除当前记录？"){
					httpRequest.request("/api/user/deleteCgKhRecord", 'GET', {
						id:this.currentid
					}).then(res => {
						httpRequest.toast(res.msg)
						if(res.code==1){
							this.init()
						}
					})
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
			lbtpriview(index, arr) {
				var i = arr; //获取当前页面的轮播图数据
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					cg_kh_id:this.listid
				}
				let url = '/api/user/cgKhRecordIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
						this.$forceUpdate()
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			xinjian() {
				uni.navigateTo({
					url: "/pages_xiaoshou/xinjiangenjinjl?cg_kh_id="+this.listid
				})
			},
			bianji(id) {
				uni.navigateTo({
					url: "/pages_xiaoshou/xinjiangenjinjl?cg_kh_id="+this.listid+"&id="+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.jiaolt{
		width: 180rpx;
		height: 180rpx;
	}
	.tupan {
		width: 140rpx;
		height: 140rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	page {
		background: #F5F5F5;
	}

	.shangj {
		margin-top: 30rpx;
	}

	.shangj:first-child {
		margin-top: 0rpx;
	}
</style>